StringScanner.ReplaceSmatch Function

Syntax

Result_Flag as L = ReplaceSmatch as l(pattern as c,replace as c)

Arguments

Result_Flag

True indicates that the replacement was done.

pattern

The text that you want to find in the buffer. You may use the "?" (single character) and "*" (any number of characters) expressions.

replace

The text to substitute for Find_Text.

Description

Look for an smatch pattern, and replace it if found.

Discussion

The <StringScanner>.ReplaceSmatchI() function replaces the first instance of Find_Text (case insensitive) with Replace_Text, if it can be found between the offset and the end of the buffer.The offset is positioned immediately after Replace_Text.

Example

dim scanner as P
dim txt as C
txt = <<%text%
This is wonderful text
written by a great writer
%text%
scanner = stringscanner.create(txt)
? scanner.replacesmatchi("w*ful", "windful")
= .T.
? scanner.GetToOffset()
= "This is windful"
? scanner.GetRemainder()
=prose written
by a technical writer of note.

See Also